package com.shuogesha.platform.feign;

import static com.shuogesha.common.web.mongo.SimplePage.cpn;

import java.io.UnsupportedEncodingException;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import com.shuogesha.platform.client.UnifiedUserFeignClient;
import com.shuogesha.platform.entity.UnifiedUser;

@RestController
@RequestMapping("/api/unifiedUser/")
public class UnifiedUserFeignAct {
	@RequestMapping(value = "/list")
	public Object v_list(String name, Integer pageNo, Integer pageSize) throws UnsupportedEncodingException {
		return unifiedUserFeignClient.list(name, cpn(pageNo), pageSize);
	}

	@RequestMapping(value = "/get")
	public Object v_get(Long id) {
		return unifiedUserFeignClient.get(id);
	}

	@RequestMapping(value = "/save", method = RequestMethod.POST)
	public Object o_save(@RequestBody UnifiedUser bean) {

		return unifiedUserFeignClient.save(bean);
	}

	@RequestMapping(value = "/update", method = RequestMethod.POST)
	public Object o_update(@RequestBody UnifiedUser bean) {
		return unifiedUserFeignClient.update(bean);
	}

	@RequestMapping(value = "/delete")
	public Object o_delete(Long[] ids) {
		return unifiedUserFeignClient.delete(ids);
	} 

	@Autowired
	public UnifiedUserFeignClient unifiedUserFeignClient;
	
	//其他操作
	@RequestMapping(value = "/updateLoginInfo", method = RequestMethod.POST)
	public Object updateLoginInfo(@RequestBody UnifiedUser bean){
		return unifiedUserFeignClient.updateLoginInfo(bean);
	} 
	@RequestMapping(value = "/login")
	public Object login(String username, String password, String ip){
		return unifiedUserFeignClient.login(username,password,ip);
	} 
	
	@RequestMapping(value = "/findById")
	public Object findById(@RequestParam("id") Long id){
		return unifiedUserFeignClient.findById(id);
	} 
	
	@RequestMapping(value = "/unifiedUser/reg")
	public Object reg(String realname,String username, String password,
			String email, String phone,String sex, String ip, String type,String avatar) {
		return unifiedUserFeignClient.reg(realname, username, password, email, phone, sex, ip, type, avatar);
	}
	
}
